<?php
/**----------------------------------------------------------------------
 * Purpose： IndexController Class
 * 
 * CreateDate : 2014/09/18
 * Description：
 * 		Index controller
 * 
 * @package	 	C-UNIT Class
 * @author	 	C-UNIT SQUARE Co.,Ltd. <info@c-unit.co.jp>
 * @copyright  	Copyright(c) 2014　C-UNIT SQUARE Co.,Ltd. All Rights Reserved.
 * @license		C-UNIT SQUARE Co.,Ltd.
 ------------------------------------------------------------------------*/

class IndexController extends Zend_Controller_Action
{
    /**-------------------------------------------------------------------
     * Init context Switch Ajax
     --------------------------------------------------------------------*/
    public function init()
    {
        $objContextSwitch = $this->_helper->getHelper('contextSwitch');
        $objContextSwitch->addActionContext('index', 'json')
                         ->initContext();
    }

    /**-------------------------------------------------------------------
     * Get array User, set View
     --------------------------------------------------------------------*/
    public function indexAction()
    {
        $this->view->domain_path = DOMAIN_PATH;

        // set number of items on one page
        $intItemPerPage = 10;

        // set number of page appear on screeen        
        $intPageRange = 6;

        // get current page from request, default = 1
        $intCurrentPage = $this->getRequest()->getPost('page', 1);

        // declare object Model_User
        $objUser = new Model_User();

        // get object paging 
        $objPaginator = $objUser->pagingUser($intItemPerPage, $intPageRange, $intCurrentPage);

        // array contents of current items
        $this->view->arrUser = $objPaginator;

        // get object page: previous, next, pageInRange, ...
        $objPage = $objPaginator->getPages();

        // get properties of object page: previous, next, pageInRange, ...
        $this->view->objPage = get_object_vars($objPage);
    }

    /**-------------------------------------------------------------------
     * Get Id from URL, set View
     --------------------------------------------------------------------*/
    public function detailAction()
    {
        $strId = $this->getRequest()
                      ->getParam('id');
        echo $strId; 
    }
}